package com.ihr360.payroll.service.payroll.convertor;

import com.ihr360.commons.model.IConvertor;
import com.ihr360.payroll.config.SalaryFieldCategoryEntity;
import com.ihr360.payroll.config.SalaryFieldTypeEntity;
import com.ihr360.payroll.model.dto.salary.basecode.SalaryFieldCategory;
import com.ihr360.payroll.model.dto.salary.basecode.SalaryFieldType;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @author richey
 */
@Component
public class SalaryFieldTypeConvertor implements IConvertor<SalaryFieldTypeEntity, SalaryFieldType> {
    @Override
    public SalaryFieldType convertEntityToDto(SalaryFieldTypeEntity entity) {
        return null;
    }

    @Override
    public SalaryFieldTypeEntity convertDtoToEntity(SalaryFieldType dto) {
        SalaryFieldTypeEntity entity = new SalaryFieldTypeEntity();
        BeanUtils.copyProperties(dto, entity);

        SalaryFieldCategory salaryFieldCategory = dto.getCategory();
        if (salaryFieldCategory != null) {
            SalaryFieldCategoryEntity salaryFieldCategoryEntity = new SalaryFieldCategoryEntity();
            BeanUtils.copyProperties(salaryFieldCategory, salaryFieldCategoryEntity);
            entity.setCategory(salaryFieldCategoryEntity);
        }
        return entity;
    }
}
